<?php

/**
 * AimProduct form base class.
 *
 * @method AimProduct getObject() Returns the current form's model object
 *
 * @package    sf_sandbox
 * @subpackage form
 * @author     Hindua88
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseAimProductForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'          => new sfWidgetFormInputHidden(),
      'name'        => new sfWidgetFormInputText(),
      'thumbnail'   => new sfWidgetFormInputText(),
      'intro'       => new sfWidgetFormInputText(),
      'detail'      => new sfWidgetFormInputText(),
      'price'       => new sfWidgetFormInputText(),
      'quantity'    => new sfWidgetFormInputText(),
      'color_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AimColor'), 'add_empty' => true)),
      'supplier_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AimSupplier'), 'add_empty' => true)),
      'group_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AimGroup'), 'add_empty' => true)),
      'type_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('AimProductType'), 'add_empty' => true)),
      'viewer'      => new sfWidgetFormInputText(),
      'created_at'  => new sfWidgetFormDateTime(),
      'updated_at'  => new sfWidgetFormDateTime(),
      'is_active'   => new sfWidgetFormInputCheckbox(),
    ));

    $this->setValidators(array(
      'id'          => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'name'        => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'thumbnail'   => new sfValidatorString(array('max_length' => 255, 'required' => false)),
      'intro'       => new sfValidatorPass(array('required' => false)),
      'detail'      => new sfValidatorPass(array('required' => false)),
      'price'       => new sfValidatorNumber(array('required' => false)),
      'quantity'    => new sfValidatorInteger(array('required' => false)),
      'color_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AimColor'), 'required' => false)),
      'supplier_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AimSupplier'), 'required' => false)),
      'group_id'    => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AimGroup'), 'required' => false)),
      'type_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('AimProductType'), 'required' => false)),
      'viewer'      => new sfValidatorInteger(array('required' => false)),
      'created_at'  => new sfValidatorDateTime(),
      'updated_at'  => new sfValidatorDateTime(),
      'is_active'   => new sfValidatorBoolean(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('aim_product[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'AimProduct';
  }

}
